﻿using EventHandlerDemo.Domain.Bases.Events;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;

namespace EventHandlerDemo.Domain.Bases;

public class Entity : IGeneratesDomainEvents
{
    [NotMapped]
    public virtual ICollection<DomainEvent> DomainEvents { get; }

    public Entity()
    {
        DomainEvents = new Collection<DomainEvent>();
    }

    protected void Raise(DomainEvent domainEvent)
    {
        DomainEvents.Add(domainEvent);
    }
}
